package Tests;

import static org.junit.Assert.*;

import org.junit.Test;

import Entities.Entity;
import Entities.EntityType;

public class AnEntityShould {

	@Test
	public void createAnEntityFromAThreeArgumentConstructor() {
		Entity entity = new Entity("Bob", EntityType.PLAYER, 400);
		assertEquals(true, entity.getName().equals("Bob"));
		assertEquals(400, entity.getCurrentDamageTaken(), 0);
		assertEquals(EntityType.PLAYER, entity.getType());
	}
	
	@Test
	public void createAnEntityFromAFiveArgumentConstructore() {
		Entity entity = new Entity("Bob", EntityType.PLAYER, "Art of War", 4000, 63780);
		assertEquals(true, entity.getName().equals("Bob"));
		System.out.println(entity.getDeck());
		assertEquals(4000, entity.getDeck().get(0).getTotalAmount(), 0);
		assertEquals(EntityType.PLAYER, entity.getType());
		assertEquals("Art of War", entity.getDeck().get(0).getName());
		assertEquals(63780, entity.getTimer().getStartTime());
	}
	
	@Test
	public void whenAnAbilityIsAddedThatExistsTheDamageShouldBeUpdated() {
		Entity entity = new Entity("Bob", EntityType.PLAYER, "Art of War", 4000, 63780);
		entity.addAbilityToDeck("Art of War", 6000);
		assertEquals("Art of War", entity.getDeck().get(0).getName());
		assertEquals(6000, entity.getDeck().get(0).getMaxHit());
		assertEquals(10000, entity.getDeck().get(0).getTotalAmount());
		assertEquals(0, entity.indexIfAbilityFound("Art of War"));
	}
	
	@Test
	public void whenAnAbilityIsNotInTheDeckTheListShouldReturnMinusOne() {
		Entity entity = new Entity("Bob", EntityType.PLAYER, "Art of War", 4000, 63780);
		assertEquals(-1, entity.indexIfAbilityFound("Joy of Sex"));
	}
	
	@Test
	public void correctlyCalculateAPercentageGivenTheCorrectInput() {
		Entity entity = new Entity("Bob", EntityType.PLAYER, "Art of War", 4000, 63780);
		assertEquals(30, entity.calculatePercentage(30, 100), 0);
		assertEquals(0, entity.calculatePercentage(-1, 100), 0);
	}
	
	@Test
	public void correctlyCalculateDPSGivenThenCorrectInput() {
		Entity entity = new Entity("Bob", EntityType.PLAYER, "Art of War", 4000, 63780);
		entity.calculateDamagePerSecond(-1, 4000);
		entity.calculateDamagePerSecond(1, 4000);
		assertEquals(4000, entity.getDamagePerSecond() , 0);
	}

	@Test
	public void correctlyCalculateHPSGivenThenCorrectInput() {
		Entity entity = new Entity("Bob", EntityType.PLAYER, "Art of War", 4000, 63780);
		entity.calculateHealsPerSecond(-1, 4000);
		entity.calculateHealsPerSecond(1, 4000);
		assertEquals(4000, entity.getHealsPerSecond() , 0);
	}
	
	@Test
	public void changeValuesWhenToldTo() {
		Entity entity = new Entity("Bob", EntityType.PLAYER, "Art of War", 4000, 63780);
		entity.setCurrentDamageDone(4000);
		entity.setCurrentDamageTaken(3000);
		entity.setName("Dave");
		entity.setCurrentHealingDone(2000);
		entity.setCurrentHealingReceived(1000);
		entity.setType(EntityType.ADDMOB);
		assertEquals(4000, entity.getCurrentDamageDone(),0);
		assertEquals(3000, entity.getCurrentDamageTaken(), 0);
		assertEquals("Dave", entity.getName());
		assertEquals(2000, entity.getCurrentHealingDone(), 0);
		assertEquals(1000, entity.getCurrentHealingReceived(), 0);
		assertEquals(EntityType.ADDMOB, entity.getType());
	}
	
}
